import java.util.Random;
import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args) {
        int i = 0;
        int time = 0;
        int flg = 0;

        Random random = new Random(100);
        Scanner scanner = new Scanner(System.in);
        int ret = random.nextInt(100);
        System.out.println(ret);
        System.out.println("开始猜数字");

        while (flg !=1){
        while (i != 1) {
            System.out.println("请输入你所猜测的数字");
            int number = scanner.nextInt();
            if (ret == number) {
                i = 1;
                flg = 1;
                System.out.println("恭喜你，猜测正确");
                time++;
            } else if (number > ret) {
                System.out.println("数猜大了");
                time++;
            } else {
                System.out.println("数猜小了");
                time++;
            }
        }
        }
        System.out.println("恭喜你使用了"+time+"次数通关游戏");
    }
}
